package com.tx.studentManager.model;

import java.util.List;

public class Page {
	/**
	 * 每页显示数量
	 */
	private int pageSize;
	/**
	 * 总记录数(totalCount)
	 */
	private int totalCount;
	/**
	 * 总页数
	 */
	private int pageCount;
	/**
	 * 当前页,从0开始计算
	 */
	private int pageNo;
	/**
	 * 起始点
	 */
	private int beginIndex;
	/**
	 * 查询到的结果
	 */
	private List<?> list;
	/**
	 * 查询条件
	 */
	private Object condition;
	/**
	 * 是否有上一页
	 */
	private boolean hasPrePage;
	/**
	 * 是否有下一页
	 */
	private boolean hasNextPage;

	/**
	 * 全部参数构造
	 * 
	 * @param numPerPage
	 * @param totalCount
	 * @param pageSize
	 * @param pageNo
	 * @param beginIndex
	 * @param list
	 * @param condition
	 * @param hasPrePage
	 * @param hasNextPage
	 */
	public Page(int pageSize, int totalCount, int pageCount, int pageNo,
			int beginIndex, List<?> list, Object condition, boolean hasPrePage,
			boolean hasNextPage) {
		this.pageSize = pageSize;
		this.pageCount= pageCount;
		this.pageNo = pageNo;
		this.totalCount = totalCount;
		this.beginIndex = beginIndex;
		this.list = list;
		this.condition = condition;
		this.hasPrePage = hasPrePage;
		this.hasNextPage = hasNextPage;
	}

	/**
	 * 常用属性构造，适用于结果集
	 * 
	 * @param totalCount 总结果数
	 * @param numPerPage 每页数
	 * @param pageNo 当前页号
	 * @param list 结果集
	 */
	public Page(int totalCount, int pageSize, int pageNo, List<?> list) {
		this.totalCount = totalCount;
		this.pageSize = pageSize;
		this.pageNo = pageNo;
		this.list = list;
	}

	// 构造函数，默认
	public Page() {
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getBeginIndex() {
		this.beginIndex=(this.pageNo-1)*this.pageSize;
		return beginIndex;
	}

	public void setBeginIndex(int beginIndex) {
		this.beginIndex = beginIndex;
	}

	public List<?> getList() {
		return list;
	}

	public void setList(List<?> list) {
		this.list = list;
	}

	public Object getCondition() {
		return condition;
	}

	public void setCondition(Object condition) {
		this.condition = condition;
	}

	public boolean isHasPrePage() {
		return hasPrePage;
	}

	public void setHasPrePage(boolean hasPrePage) {
		this.hasPrePage = hasPrePage;
	}

	public boolean isHasNextPage() {
		return hasNextPage;
	}

	public void setHasNextPage(boolean hasNextPage) {
		this.hasNextPage = hasNextPage;
	}
/**
 * 获取实际开始序号
 * @param pageNo
 * @param numPerPage
 * @return
 */
	public static int getStartOfPage(int pageNo, int numPerPage) {
		return (pageNo-1)*numPerPage;
	}

}